package com.huobao.yunying.activitys_hehuoren;

import java.util.Map;

import org.xutils.view.annotation.ViewInject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.huobao.yunying.activitys_store.Act_Store;
import com.huobao.yunying.base.HuobaoBaseActivity;
import com.huobao.yunying.https.Http;
import com.huobao.yunying.https.HttpListener;
import com.huobao.yunying.https.HttpUtil;
import com.huobao.zhangying.R;

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class Act_Gonghuoshang_detail extends HuobaoBaseActivity {
	@ViewInject(R.id.tv_name)
	private TextView tv_name;
	@ViewInject(R.id.tv_email)
	private TextView tv_store_name;
	@ViewInject(R.id.tv_storename)
	private TextView tv_dengji;
	@ViewInject(R.id.tv_store_address)
	private TextView tv_zhuangtai;
	@ViewInject(R.id.tv_tongxun)
	private TextView tv_address;

	private String store_id;

	@Override
	protected int getContentView() {
		return R.layout.layout_gonghuoshang_detail;
	}

	@Override
	protected String getTitleText() {
		return "店铺详情";
	}

	@Override
	protected void init() {
		store_id = getIntent().getStringExtra("store_id");
		getDetail();
	}

	private void getDetail() {
		Map<String, String> map = HttpUtil.getParams("app", "partner", "act", "shopshow", "s_id", store_id);
		Http.getInstant().sendRequest(context, map, new HttpListener() {

			@Override
			public void onHttpSuccess(String result) {
				JSONObject jsonObject = JSON.parseObject(result);
				jsonObject = jsonObject.getJSONObject("retval");
				tv_name.setText(jsonObject.getString("owner_name"));

				tv_store_name.setText(jsonObject.getString("store_name"));
				tv_address.setText(jsonObject.getString("region_name"));
				tv_zhuangtai.setText(jsonObject.getIntValue("state") == 1 ? "开启" : "关闭");
				tv_dengji.setText(jsonObject.getIntValue("sgrade") == 1 ? "系统默认" : "");
				tv_store_name.setOnClickListener(new OnClickListener() {
					
					@Override
					public void onClick(View v) {
						Intent intent = new Intent(context, Act_Store.class);
						intent.putExtra("id", store_id);
						startActivity(intent);
					}
				});
			}

			@Override
			public void onHttpError(String error) {

			}
		});
	}

}
